import java.util.HashSet;
import java.util.Set;

import static java.util.Arrays.sort;

/**
 * @author yan
 * @date 2025/8/21
 */
public class ti128 {
    class Solution {
        public int longestConsecutive(int[] nums) {
            Set<Integer> set = new HashSet<>();
            for (int num : nums){
                set.add(num);
            }
            int max = 0;
            for (int x : set){
                if(set.contains(x-1)){
                    continue;
                }
                int y=x+1;
                while (set.contains(y)){
                    y++;
                }
                max = Math.max(max,y-x);
            }
            return max;
        }
    }

    public static void main(String[] args) {

    }
}
